
require(['../config'],()=>{
    require(['template','header','footer'],(template)=>{
        class Index {
            constructor(){
                this.getId().then(()=>{
                    this.render()
                    this.paging()
                })
            }

            getId(){
                let id = Number(window.location.search.slice(4))
                return new Promise(resolve=>{
                    $.get('http://rap2api.taobao.org/app/mock/239068/list',{ id },resp=>{
                        this.resp = resp.body
                        resolve()
                    })
                })
            }

            render() {
                let str1 = template('temp1',{ list:this.resp.list.shop })
                $('#shop1').html(str1)

                let str2 = template('temp2',{ list:this.resp.list.item })
                $('#box3').html(str2)
                    
                let str3 = template('temp3',{ list:this.resp.item })
                $('#box4').html(str3)

                let str4 = template('temp4',{ list:this.resp.title })
                $('#box5').html(str4)
            }



            paging () {
                const that = this
                $('#box5 a').eq(0).siblings().addClass('ac')
                $('#box5').on('click','.ac',function(){
                    const id = $(this).attr('id')
                    $.get('http://rap2api.taobao.org/app/mock/239068/list',{ id },resp=>{
                        this.resp = resp.body
                        let str3 = template('temp3',{ list:this.resp.item })
                        $('#box4').html(str3)
                    })
                    
                })
            }
            
        }
        new Index()
    })
})